package main

import "fmt"

func EliminateAdjacentDuplicates(nums []int) (s []int) {
	l := len(nums)
	if l < 2 {
		s = nums
		return
	}
	s = append(s, nums[0])

	var tmp int = nums[0]
	for i := 1; i < l; i++ {
		if nums[i] != tmp {
			tmp = nums[i]
			s = append(s, nums[i])
			continue
		}
	}
	return
}
func find132pattern(nums []int) bool {
	x, y := 0, 0
	nums = EliminateAdjacentDuplicates(nums)
	fmt.Println(nums)

	for i := 0; i < len(nums)-2; i++ {
		x = nums[i]
		for j := i + 1; j < len(nums)-1; j++ {
			if nums[j] > x {
				y = nums[j]
				for p := j + 1; p < len(nums); p++ {
					if x < nums[p] && nums[p] < y {
						return true
					}

				}
			}
		}
	}
	return false
}

func main() {
	var input []int = []int{1, 2, 2, 3, 2}
	fmt.Println(find132pattern(input))
}
